package cosc617_blackteam;

/**
 * Command for returning the menu specified by the MenuSpecialAttribute parameter
 * @author Laura Semesky
 */
public class CmdGetAttributeMenu implements I_Command {

	private I_InfoAggregator infoAggr;
	MenuSpecialAttribute attribute;
	
	/**
	 * @param infoAggr the receiver
	 * @param attribute the type of menu to return
	 */
	public CmdGetAttributeMenu(I_InfoAggregator infoAggr, MenuSpecialAttribute attribute)
	{
		this.infoAggr = infoAggr;
		this.attribute = attribute;
	}
	
	@Override
	public Object execute() {
		I_MenuIterator i= infoAggr.getMenu().getSpecialAttributeMenuIterator(attribute);
		Menu m = new Menu();
		while(i.hasNext()){
			m.addMenuItem(i.next().copy());
		}
		return m;
	}

}
